<template>
  <div class="page-container">
    <button class="back-button" @click="goToHome">
      <span class="icon-arrow-left"></span>
      返回首页
    </button>
    
    <div class="header-section">
      <h1>商家类型客户管理</h1>
      <p>专门处理商家客户的相关事务，包括合作管理和服务记录</p>
    </div>
    
    <div class="stats-cards">
      <div class="stat-card">
        <div class="stat-title">合作商家总数</div>
        <div class="stat-value">128</div>
        <div class="stat-change positive">+5 本月</div>
      </div>
      <div class="stat-card">
        <div class="stat-title">活跃商家数</div>
        <div class="stat-value">96</div>
        <div class="stat-change positive">+2 本月</div>
      </div>
      <div class="stat-card">
        <div class="stat-title">待处理工单</div>
        <div class="stat-value">12</div>
        <div class="stat-change negative">-3 本周</div>
      </div>
      <div class="stat-card">
        <div class="stat-title">本月新增合作</div>
        <div class="stat-value">8</div>
        <div class="stat-change positive">+3 较上月</div>
      </div>
    </div>
    
    <div class="action-bar">
      <div class="search-filter">
        <input 
          type="text" 
          placeholder="搜索商家名称..." 
          class="search-input"
        >
        <select class="filter-select">
          <option value="">全部行业</option>
          <option value="retail">零售业</option>
          <option value="food">餐饮</option>
          <option value="service">服务业</option>
          <option value="manufacturing">制造业</option>
        </select>
      </div>
      <button class="primary-btn">新增合作商家</button>
    </div>
    
    <div class="card">
      <table class="data-table">
        <thead>
          <tr>
            <th>商家名称</th>
            <th>行业类型</th>
            <th>联系人</th>
            <th>联系方式</th>
            <th>合作状态</th>
            <th>合作日期</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>优品超市</td>
            <td>零售业</td>
            <td>赵经理</td>
            <td>138****5678</td>
            <td><span class="status active">正常</span></td>
            <td>2022-03-15</td>
            <td class="action-buttons">
              <button class="btn-view">详情</button>
              <button class="btn-cooperation">合作记录</button>
              <button class="btn-service">服务工单</button>
            </td>
          </tr>
          <tr>
            <td>美味餐厅</td>
            <td>餐饮</td>
            <td>钱老板</td>
            <td>139****1234</td>
            <td><span class="status active">正常</span></td>
            <td>2022-05-20</td>
            <td class="action-buttons">
              <button class="btn-view">详情</button>
              <button class="btn-cooperation">合作记录</button>
              <button class="btn-service">服务工单</button>
            </td>
          </tr>
          <tr>
            <td>快捷物流</td>
            <td>服务业</td>
            <td>孙主管</td>
            <td>137****8901</td>
            <td><span class="status expired">已到期</span></td>
            <td>2021-11-05</td>
            <td class="action-buttons">
              <button class="btn-view">详情</button>
              <button class="btn-cooperation">合作记录</button>
              <button class="btn-renew">续约</button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    
    <div class="pagination">
      <button class="page-btn">上一页</button>
      <button class="page-btn active">1</button>
      <button class="page-btn">2</button>
      <button class="page-btn">3</button>
      <button class="page-btn">...</button>
      <button class="page-btn">13</button>
      <button class="page-btn">下一页</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MerchantCustomer',
  methods: {
    goToHome() {
      this.$router.push('/home');
    }
  }
}
</script>

<style scoped>
.page-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.header-section {
  margin: 20px 0 30px;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
}

.header-section h1 {
  color: #2c3e50;
  margin-bottom: 10px;
  font-size: 24px;
}

.header-section p {
  color: #7f8c8d;
  font-size: 14px;
  margin: 0;
}

.stats-cards {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 200px;
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-title {
  color: #7f8c8d;
  font-size: 14px;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 5px;
}

.stat-change {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.positive {
  color: #2ecc71;
}

.negative {
  color: #e74c3c;
}

.positive::before {
  content: '↑';
}

.negative::before {
  content: '↓';
}

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.search-filter {
  display: flex;
  gap: 10px;
}

.search-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 250px;
  font-size: 14px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  font-size: 14px;
}

.primary-btn {
  background-color: #3498db;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.primary-btn:hover {
  background-color: #2980b9;
}

.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #f5f5f5;
  font-size: 14px;
}

.data-table th {
  background-color: #f9f9f9;
  font-weight: 600;
  color: #34495e;
}

.data-table tbody tr:hover {
  background-color: #f9f9f9;
}

.status {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.status.active {
  background-color: #eafaf1;
  color: #27ae60;
  border: 1px solid #27ae60;
}

.status.expired {
  background-color: #fdedeb;
  color: #e74c3c;
  border: 1px solid #e74c3c;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-view, .btn-cooperation, .btn-service, .btn-renew {
  padding: 4px 8px;
  border: none;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-view {
  background-color: #3498db;
  color: white;
}

.btn-cooperation {
  background-color: #9b59b6;
  color: white;
}

.btn-service {
  background-color: #f39c12;
  color: white;
}

.btn-renew {
  background-color: #2ecc71;
  color: white;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 20px 0;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background-color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
}

.page-btn.active {
  background-color: #3498db;
  color: white;
  border-color: #3498db;
}

.page-btn:hover:not(.active) {
  border-color: #3498db;
  color: #3498db;
}

.back-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s;
  margin-right: 20px;
  font-weight: 500;
}

.back-button:hover {
  background: #2980b9;
  transform: translateY(-2px);
}

.icon-arrow-left::before {
  content: '←';
}
</style>